import request from '@/utils/request.js'

// 获取科目列表
export function getSubjectList() {
  return request({
    url: 'subjects/list',
    method: 'GET'
  })
}

// 获取科目详情
export function getSubjectDetail(id) {
  return request({
    url: `/api/subjects/${id}`,
    method: 'GET'
  })
}

// 获取科目分类
export function getSubjectCategories() {
  return request({
    url: '/api/subjects/categories',
    method: 'GET'
  })
}

// 根据分类获取科目
export function getSubjectsByCategory(categoryId) {
  return request({
    url: `/api/subjects/category/${categoryId}`,
    method: 'GET'
  })
}

// 获取所有科目（用于课程创建）
export function getAllSubjects() {
  return request({
    url: 'subjects/list',
    method: 'GET'
  })
}

// 直接从数据库获取科目列表
export function getSubjectsListDirect() {
  return request({
    url: 'subjects/list',
    method: 'GET'
  })
}

// 从数据库获取科目数据
export function getSubjectsFromDB() {
  return request({
    url: 'subjects/list',
    method: 'GET'
  })
}

// 根据ID获取科目信息
export function getSubjectById(id) {
  return request({
    url: `subjects/${id}`,
    method: 'GET'
  })
}

// 获取科目课程映射关系
export function getSubjectCourseMapping() {
  return request({
    url: 'subjects/course-mapping',
    method: 'GET'
  })
}

// 导出subjectApi对象
export const subjectApi = {
  getSubjectList,
  getSubjectDetail,
  getSubjectCategories,
  getSubjectsByCategory,
  getAllSubjects,
  getSubjectsListDirect,
  getSubjectsFromDB,
  getSubjectById,
  getSubjectCourseMapping
}